#!/bin/bash 

LIB_HOME="/opt/pd/datacenter/shells/seqaccess/mails/"

main_class="com.sohuauto.autodc_temp.main.DemoEmail"
stat_date="`date +%Y%m%d -d "-7 days"`"
end_date="`date +%Y%m%d -d "-1 days"`"
# 主题不能有空格
subject="【搜狐汽车数据中心】【百度SEM流量】【`date +%Y年%m月%d日 -d '-7 days'`至`date +%Y年%m月%d日 -d '-1 days'`】"
to="shaopengli@sohu-inc.com,haixinwang@sohu-inc.com,zhengfengzuo@sohu-inc.com,zhaosong@pzoom.com"
#to="fanhx9@163.com,fanhx825@163.com,zhengfengzuo@sohu-inc.com"
cc="hongxingfan@sohu-inc.com"
templateLoaderPath="/opt/pd/datacenter/shells/seqaccess/mails/template"
templateName="demo1.ftl"
attachFile="/opt/pd/datacenter/shells/seqaccess/mails/${stat_date}-${end_date}.xls"
# 没有附件情况
# attachFile=""
sql="SELECT stat_date,from_source_zhname,to_block_zhname,pv,uv,dpv,duv FROM seqaccess_stat_source_to_block WHERE from_source_id IN (500237) AND to_block_id IN (100008,100011,100021,100720,100721) AND stat_date BETWEEN ${stat_date} AND ${end_date} ORDER BY stat_date DESC, from_source_zhname,to_block_zhname ASC"

export JAVA_LIBRARY_PATH=/opt/sohuhadoop/hadoop/lib/native/Linux-amd64-64
export JAVA_HOME=/usr/local/jdk
. /user/autolog/.bash_profile
export CLASSPATH=.:$LIB_HOME/DemoEmail.jar

/usr/local/jdk/bin/java -Xms4096m -Xmx4096m $main_class -start "${stat_date}" -end "${end_date}" -subject "${subject}" -to "${to}" -cc "${cc}" -templateLoaderPath "${templateLoaderPath}" -templateName "${templateName}" -attachFile "${attachFile}" -sql "${sql}"
